package com.chencs.biz.special.service;

import com.chencs.biz.model.service.ModelService;
import com.chencs.vo.biz.special.SpecialModel;
import com.chencs.webmvc.rest.RestFullTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by fangzehua on 2017/7/8.
 */

@Service
public class SpecialService {

    private static final Logger logger = LoggerFactory.getLogger(SpecialService.class.getName());

    @Autowired
    RestFullTemplate restTemplate;
    /**标志远程服务url**/
    private static final String URLPATH = "service-common/special/";


    public String specialList() throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "getSpecialList", String.class,"");
        logger.info("SpecialService getSpecialList zuulGateWay result {}", ret);
        return ret;
    }

    public String getSpecialProductById(String sid) throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "getSpecialProductById", String.class,sid);
        logger.info("SpecialService getSpecialProductById zuulGateWay result {}", ret);
        return ret;
    }

    public String findSpecialById(String sid) throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "findSpecialById", String.class,sid);
        logger.info("SpecialService findSpecialById zuulGateWay result {}", ret);
        return ret;
    }

    public String delSpecial(String sid) throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "delSpecial", String.class,sid);
        logger.info("SpecialService delSpecial zuulGateWay result {}", ret);
        return ret;
    }


    public String delSpecialProduct(String id) throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "delSpecialProduct", String.class,id);
        logger.info("SpecialService delSpecialProduct zuulGateWay result {}", ret);
        return ret;
    }

    public String saveSpecialProduct(String id) throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "insertSpecialProduct", String.class,id);
        logger.info("SpecialService insertSpecialProduct zuulGateWay result {}", ret);
        return ret;
    }

    public String insertSpecial(SpecialModel model) throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "insertSpecial", String.class,model);
        logger.info("SpecialService insertSpecial zuulGateWay result {}", ret);
        return ret;
    }

    public String updateSpecial(SpecialModel model) throws Exception{
        String ret = restTemplate.postForObject(URLPATH + "updateSpecial", String.class,model);
        logger.info("SpecialService updateSpecial zuulGateWay result {}", ret);
        return ret;
    }


}
